package ProducerConsumer.condition;

import ProducerConsumer.condition.MyBlockqueueCondition;

public class MyConditionImpl {
    public static void main(String[] args) {
        MyBlockqueueCondition queue = new MyBlockqueueCondition(10);

        Runnable producer = () -> {
            while (true) {
                try {
                    queue.put(new Object());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };

        new Thread(producer).start();
        new Thread(producer).start();

        Runnable consumer = () -> {
            while (true) {
                try {
                    Object o = queue.take();
                    System.out.println(">>>o:" + o);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };

        new Thread(consumer).start();
        new Thread(consumer).start();
    }
}
